#include "stdafx.h"
#include "defcolor_btn.h"
#include "bmp_file_op.h"
#include "frame_top.h"
#include <utility/api_tools.h>
#include "dll_object.h"
#include "Page_Main.h"

defcolor_btn::defcolor_btn()
{
	this->pwnd_ = NULL;
}

defcolor_btn::~defcolor_btn()
{

};

BEGIN_MESSAGE_MAP(defcolor_btn, CButton)
	//{{AFX_MSG_MAP(defcolor_btn)
	ON_CONTROL_REFLECT(BN_CLICKED, OnClicked)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void defcolor_btn::OnClicked()
{
	CRect rt,rc;
	GetWindowRect(rc);
	::GetWindowRect(this->pwnd_->GetSafeHwnd(), rt);
	
	int left = rc.left - rt.left;
	int top = rc.top - rt.top;
	left -= 6;
	top -= 5;
	CPoint p;
	p.x = (left + left + rc.Width()) / 2;
	p.y = (top + top + rc.Height()) / 2;

	RGBQUAD rgbcx = this->pcx_image_->GetPixelColor(p.x, 65 - p.y);
	COLORREF col = RGB(rgbcx.rgbRed,rgbcx.rgbGreen,rgbcx.rgbBlue);
	::SendMessage(GetParent()->GetParent()->GetSafeHwnd(), WM_ASPECT_CHANGE, (WPARAM)"", col);
}

history_btn::history_btn()
{
	this->pwnd_ = NULL;
}

history_btn::~history_btn()
{

};

BEGIN_MESSAGE_MAP(history_btn, CButton)
	//{{AFX_MSG_MAP(defcolor_btn)
	ON_CONTROL_REFLECT(BN_CLICKED, OnClicked)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void history_btn::OnClicked()
{
	::SendMessage(GetParent()->GetSafeHwnd(), WM_ASPECT_CHANGE, (WPARAM)(LPCTSTR)this->theme_, this->col_);
}